<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <!-- 
        http://127.0.0.1:5500/day12.js-20201120/8.location%E5%AF%B9%E8%B1%A1.html?username=trump&age=20#sectionone
        
        protocol:http 网络协议(超文本传输协议) https 加密连接
        hosrtname: 127.0.0.1 服务器地址(本地服务器127.0.0.1)
        port: 5500服务器端口号 网站(http协议默认端口号88 在浏览器里面一般给省略 https默认端口是443 一般也会省略)
        pathname: /day12.js-20201120/8.location%E5%AF%B9%E8%B1%A1.html 路径
        search: ?username=trump&age=20 get传值的参数数据 ?后面跟着两条数据
                username 参数名称  =trump参数的值
                & 连接多个参数
                age 参数名称  =20参数的值
        hash:#sectionone  锚链接 (vue)/user/login用到 

        https://baidu.com/user/image/index.html?path=/usr/local/&img=abc.jpg#login
        protocol  协议:https 加密滴
        hostname:baidu.com
        port: 443
        pathname: /user/image/index.html
        search: ?path=/usr/local/&img=abc.jpg
        hash:   #login

        location.href='http://baiud.com' 相当于给location一个指定的地址，直接跳转
        location.assign='http://baiud.com' 相当于给location一个指定的地址，直接跳转
     -->
    <!-- <script>
        console.log('location.protocol',location.protocol);
        console.log('location.hostname',location.hostname);
        console.log('location.port',location.port);
        console.log('location.pathname',location.pathname);
        console.log('location.search',location.search);
        console.log('location.hash',location.hash);
    </script> -->
</head>
<body>
    
    <script>
        var url='http://baidu.com/image/产品.html?name=刘永好#hello';
        var encodeURL=encodeURI(url);
        console.log('encodeURI编码的结果=>',encodeURL);


        var str='http://baidu.com/image/%E4%BA%A7%E5%93%81.html?name=%E5%88%98%E6%B0%B8%E5%A5%BD#hello';
        var decodeStr=decodeURI(str);
            console.log('decodeURI解码的网址==>',decodeStr);


        var encodeURL2=encodeURIComponent(url);
        console.log('encodeURIComponent编码结果=>',encodeURL2);
        console.log("decodeURIComponent解码==>",decodeURIComponent(encodeURL2));

        console.log('encodeURI编码的地址用 decodeURIComponent解码',decodeURIComponent(encodeURL));
        console.log('encodeURIComponent编码的地址用 decodeURI解码',decodeURI(encodeURL2));
    </script>
    
</body>
</html>